/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意：
* 本软件为www.yixiang.co开发研制，未经购买不得使用
* 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
* 一经发现盗用、分享等行为，将追究法律责任，后果自负
*/
package co.yixiang.mall.biz.maintain.controller;

import co.yixiang.common.core.annotation.AnonymousAccess;
import co.yixiang.common.log.annotation.Log;
import co.yixiang.mall.biz.maintain.service.YxShippingMaintainService;
import co.yixiang.mall.common.maintain.domain.YxShippingMaintain;
import co.yixiang.mall.common.maintain.dto.YxShippingMaintainDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author wangxueliang
* @date 2021-03-17
*/
@AllArgsConstructor
@Api(tags = "maintain管理")
@RestController
@RequestMapping("/api/yxShippingMaintain")
public class YxShippingMaintainController {

    @Autowired
    private YxShippingMaintainService yxShippingMaintainService;

    @Log("维护费计算")
    @ApiOperation("维护费计算")
    @AnonymousAccess
    @PostMapping("/calculate")
    public int calculate(Integer money){
        int reMoney = yxShippingMaintainService.calculate(money);
        return reMoney;
    }

    @Log("平台维护费")
    @ApiOperation("平台维护费")
    @AnonymousAccess
    @GetMapping("/show")
    public ResponseEntity<List<YxShippingMaintainDto>> show(){
        List<YxShippingMaintainDto> yxShippingMaintainDto = yxShippingMaintainService.show();
        return new ResponseEntity<>(yxShippingMaintainDto,HttpStatus.OK);
    }

    @Log("平台维护费修改")
    @ApiOperation("平台维护费修改")
    @AnonymousAccess
    @PostMapping("/update")
    public void updateMaintain(@RequestBody YxShippingMaintain yxShippingMaintain){
        yxShippingMaintainService.updateMaintain(yxShippingMaintain);
    }
}
